return rc;
}
+int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus)
+{
+ int ret;
+ DECLARE_SYSCTL;
+
+ sysctl.cmd = XEN_SYSCTL_cpuinfo;
+ sysctl.u.cpuinfo.max_cpus = max_cpus;
+ set_xen_guest_handle(sysctl.u.cpuinfo.buffer, info);
+
+ if ( (ret = do_sysctl(xc_handle, &sysctl)) != 0 )
+ return ret;
+
+ if(nr_cpus)
+ *nr_cpus = sysctl.u.cpuinfo.nr_cpus;
+
+ return 0;
+}
+
+
int xc_hvm_set_pci_intx_level(
int xc_handle, domid_t dom,
uint8_t domain, uint8_t bus, uint8_t device, uint8_t intx,
int xc_sched_id(int xc_handle,
int *sched_id);
+int xc_cpuinfo(int xc_handle, int max_cpus, uint64_t *info, int *nr_cpus);
+
int xc_domain_setmaxmem(int xc_handle,
uint32_t domid,
unsigned int max_memkb);
ASSERT(v->runstate.state != new_state);
ASSERT(spin_is_locked(&per_cpu(schedule_data,v->processor).schedule_lock));
- v->runstate.time[v->runstate.state] +=
- new_entry_time - v->runstate.state_entry_time;
+ if(unlikely((v->runstate.state_entry_time - new_entry_time) > TIME_SLOP))
+ /* Local time on this CPU has been warped */
+ v->runstate.time[v->runstate.state] = new_entry_time;
+ else
+ v->runstate.time[v->runstate.state] +=
+ new_entry_time - v->runstate.state_entry_time;
v->runstate.state_entry_time = new_entry_time;
v->runstate.state = new_state;
}
}
break;
+ case XEN_SYSCTL_cpuinfo:
+ {
+ uint32_t i, nr_cpus;
+ uint64_t idletime;
+
+ nr_cpus = (op->u.cpuinfo.max_cpus > NR_CPUS) ? NR_CPUS :
+ op->u.cpuinfo.max_cpus;
+
+ for ( i = 0; i < nr_cpus; i++ )
+ {
+ if(!idle_vcpu[i])
+ /* XXX: assumes no further CPUs after first missing one */
+ break;
+
+ /* somewhat imprecise but should suffice */
+ idletime = idle_vcpu[i]->runstate.time[RUNSTATE_running] +
+ (NOW() - idle_vcpu[i]->runstate.state_entry_time);
+ if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) )
+ {
+ ret = -EFAULT;
+ break;
+ }
+ }
+
+ op->u.cpuinfo.nr_cpus = i;
+ ret = 0;
+
+ if( copy_to_guest (u_sysctl, op, 1) )
+ ret = -EFAULT;
+ }
+ break;
+
default:
ret = arch_do_sysctl(op, u_sysctl);
break;
typedef struct xen_sysctl_debug_keys xen_sysctl_debug_keys_t;
DEFINE_XEN_GUEST_HANDLE(xen_sysctl_debug_keys_t);
+/* Get physical CPU information */
+#define XEN_SYSCTL_cpuinfo 8
+struct xen_sysctl_cpuinfo {
+ /* IN variables. */
+ uint32_t max_cpus;
+ XEN_GUEST_HANDLE_64(uint64_t) buffer;
+ /* IN/OUT variables. */
+ uint32_t nr_cpus;
+};
+typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
+
struct xen_sysctl {
uint32_t cmd;
uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
struct xen_sysctl_perfc_op perfc_op;
struct xen_sysctl_getdomaininfolist getdomaininfolist;
struct xen_sysctl_debug_keys debug_keys;
+ struct xen_sysctl_cpuinfo cpuinfo;
uint8_t pad[128];
} u;
};